﻿using System;
using System.Text;

// Write a program that extracts from a given text all sentences containing given word.

namespace ExtractSentences
{
    class ExtractSentences
    {
        static string SentencesExtracter(string text, string word)
        {
            StringBuilder result = new StringBuilder();
            string[] sentances = text.Split('.', '!', '?');

            foreach (string sentace in sentances)
            {
                if (sentace.IndexOf(string.Format(" {0} ", word)) > -1 || sentace.IndexOf(string.Format(" {0}.", word)) > -1)
                {
                    result.Append(sentace).Append(". ");
                }
            }

            return result.ToString();
        }

        static void Main()
        {
            string text = "We are living in a yellow submarine. We don't have anything else. Inside the submarine is very tight. So we are drinking all the day. We will move out of it in 5 days.";
            Console.WriteLine(SentencesExtracter(text, "in"));
        }
    }
}
